package cc.cix.hq.common.core.entity.enums;

import lombok.Getter;

/**
 * 数据索引约束
 *
 * @author zhenghj
 */
@Getter
public enum DbIndexType {

    UNI_MOBILE("uni_mobile", "用户名或手机号不能重复");

    private final String value;
    private final String desc;

    DbIndexType(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static boolean isContains(String value) {
        for (DbIndexType dbIndexType : DbIndexType.values()) {
            if (value.contains(dbIndexType.getValue())) {
                return true;
            }
        }

        return false;
    }

    public static String getDescByValue(String value) {
        for (DbIndexType dbIndexType : DbIndexType.values()) {
            if (value.contains(dbIndexType.getValue())) {
                return dbIndexType.getDesc();
            }
        }

        return null;
    }

}
